package com.xdcplus.web.controller.wip;



import com.xdcplus.mom.controller.AbstractController;
import com.xdcplus.exceptions.domain.ResponseVO;

import com.xdcplus.pager.vo.PageVO;
import com.xdcplus.web.common.pojo.dto.wip.WipMarkingPrdDTO;
import com.xdcplus.web.common.pojo.dto.wip.WipMarkingPrdFilterDTO;
import com.xdcplus.web.common.pojo.vo.wip.WipMarkingPrdVO;
import com.xdcplus.web.service.wip.WipMarkingPrdService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Validation;
import javax.validation.constraints.NotNull;


/**
 * 打标单片/花篮表(WipMarkingPrd)表服务控制层
 *
 * @author Richard.Li
 * @since 2024-08-20 18:49:36
 */
@Api(tags = "打标单片/花篮表(WipMarkingPrd)") 
@Slf4j
@Validated
@RestController
@AllArgsConstructor
@RequestMapping("wipMarkingPrd")
public class WipMarkingPrdController extends AbstractController {

    @Autowired
    private WipMarkingPrdService wipMarkingPrdService;

    @ApiOperation("新增打标单片/花篮表")
    @PostMapping(value = "", produces = MediaType.APPLICATION_JSON_VALUE)
    public ResponseVO saveWipMarkingPrd(@RequestBody WipMarkingPrdDTO wipMarkingPrdDTO) {

        log.info("saveWipMarkingPrd {}", wipMarkingPrdDTO.toString());

        wipMarkingPrdDTO.setCreatedUser(getAccount());
        wipMarkingPrdService.saveWipMarkingPrd(wipMarkingPrdDTO);

        return ResponseVO.success();
    }

    @ApiOperation("修改打标单片/花篮表")
    @PutMapping(value = "", produces = MediaType.APPLICATION_JSON_VALUE)
    public ResponseVO updateWipMarkingPrd(@RequestBody WipMarkingPrdDTO wipMarkingPrdDTO) {

        log.info("updateWipMarkingPrd {}", wipMarkingPrdDTO.toString());

        wipMarkingPrdDTO.setUpdatedUser(getAccount());
        wipMarkingPrdService.updateWipMarkingPrd(wipMarkingPrdDTO);

        return ResponseVO.success();
    }

    @ApiOperation("删除打标单片/花篮表")
    @DeleteMapping(value = "/{wipMarkingPrdId}", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "path", name = "wipMarkingPrdId", dataTypeClass = Long.class, value = "打标单片/花篮表ID", required = true),
    })
    public ResponseVO deleteWipMarkingPrdLogical(@PathVariable("wipMarkingPrdId")
                                         @NotNull(message = "打标单片/花篮表ID不能为空") Long wipMarkingPrdId) {

        log.info("deleteWipMarkingPrdLogical {}", wipMarkingPrdId);

        wipMarkingPrdService.deleteWipMarkingPrdLogical(wipMarkingPrdId);

        return ResponseVO.success();
    }
    
    @ApiOperation("批量删除打标单片/花篮表")
    @DeleteMapping(value = "/deleteByIds/{wipMarkingPrdIds}", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "path", name = "wipMarkingPrdId", dataTypeClass = Long.class, value = "打标单片/花篮表ID", required = true),
    })
    public ResponseVO deleteWipMarkingPrdLogical(@PathVariable("wipMarkingPrdIds")
                                         @NotNull(message = "打标单片/花篮表ID不能为空") String wipMarkingPrdIds) {

        log.info("deleteWipMarkingPrdByIds {}", wipMarkingPrdIds);

        wipMarkingPrdService.deleteWipMarkingPrdByIds(wipMarkingPrdIds);

        return ResponseVO.success();
    }

    @ApiOperation("查询打标单片/花篮表")
    @GetMapping(value = "", produces = MediaType.APPLICATION_JSON_VALUE)
    public ResponseVO<PageVO<WipMarkingPrdVO>> findWipMarkingPrd(WipMarkingPrdFilterDTO wipMarkingPrdFilterDTO) {

        log.info("findWipMarkingPrd {}", wipMarkingPrdFilterDTO);

        Validation.buildDefaultValidatorFactory().getValidator().validate(wipMarkingPrdFilterDTO);

        return ResponseVO.success(wipMarkingPrdService.queryWipMarkingPrd(wipMarkingPrdFilterDTO));
    }


}
